//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package org.tuiofx.internal.util;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;

import javafx.event.EventTarget;
import javafx.scene.Node;
import org.tuiofx.internal.gesture.TuioTouchPoint;

public class PrettyPrintingMap {
    private final Map<EventTarget, ArrayList<TuioTouchPoint>> map;

    public PrettyPrintingMap(Map<EventTarget, ArrayList<TuioTouchPoint>> map) {
        this.map = map;
    }

    public String toString() {
        StringBuilder sb = new StringBuilder();
        Iterator<Map.Entry<EventTarget, ArrayList<TuioTouchPoint>>> iter = this.map.entrySet().iterator();
        sb.append("--------------------------------------------------------------\n");
        sb.append("NodeID |                    TouchPointIDs                     \n");
        sb.append("--------------------------------------------------------------\n");
        while (iter.hasNext()) {
            Map.Entry<EventTarget, ArrayList<TuioTouchPoint>> entry = iter.next();
            sb.append(((Node) entry.getKey()).getClass().getName()).append("      | ");
            Iterator<TuioTouchPoint> iterator = entry.getValue().iterator();

            while (iterator.hasNext()) {
                TuioTouchPoint touchPoint = iterator.next();
                sb.append(touchPoint.getSessionID()).append(" (" + touchPoint.getCursor().getSessionID() + ") ").append(" | ");
            }

            if (iter.hasNext()) {
                sb.append('\n');
            }
        }
        return sb.toString();
    }
}
